﻿namespace EyeOpen.Combinatorics.Mvc.Controllers
{
	using System.Web.Mvc;
	using EyeOpen.Validation;

	public class CsvController : Controller
	{
		public JsonResult Validate(string names)
		{
			var minimum = this.QueryString<int>("Minimum");
			var errorMessage = this.QueryString("ErrorMessage");
			
			return
				new CsvValidator().Validate(names, minimum) ?
					Json(true, JsonRequestBehavior.AllowGet) :
					Json(string.Format(errorMessage, minimum), JsonRequestBehavior.AllowGet);
		}
	}
}